
#ifdef SYPX_MEMCHECK
#include "mmgr.h"
#endif

#include "ObstacleInstance.h"

namespace SheepDefence 
{
	ObstacleInstance::ObstacleInstance()
	{
	}

	ObstacleInstance::~ObstacleInstance()
	{

	}

	ObstacleInstance::ObstacleInstance(SypX::FileInputStream& fin, Obstacle* actor, Level* level)
	{
		SypX::ErrorLogger::getLogger() << "Loading ObstacleInstance...\n";

		fin >> x;
		fin >> y;
		fin >> angle;
		dest_x = x;
		dest_y = y;

		SypX::ErrorLogger::getLogger() << "Loaded: " << x << ", " << y << ", " << angle << "\n";

		type = OBSTACLE;
		state = IDLE;
		elapsed  = 0;
		this->level = level;
		this->actor = actor;
		sprite = new SypX::SpriteInstance();
		sprite->useSprite(actor->sprite);

		sprite->setPosition(SypX::Vec3(static_cast<float>(x), static_cast<float>(y), 1.0f - y / 960.0f));	
		sprite->setActiveAngle(angle);
	}

	ObstacleInstance::ObstacleInstance(Obstacle* actor, Level* level, float x, float y, int angle)
	{
		SypX::ErrorLogger::getLogger() << "Loading ObstacleInstance...\n";

		this->x = x;
		this->y = y;
		this->angle = angle;
		dest_x = x;
		dest_y = y;

		SypX::ErrorLogger::getLogger() << "Loaded: " << x << ", " << y << ", " << angle << "\n";

		type = OBSTACLE;
		state = IDLE;
		elapsed  = 0;
		this->level = level;
		this->actor = actor;
		sprite = new SypX::SpriteInstance();
		sprite->useSprite(actor->sprite);

		sprite->setPosition(SypX::Vec3(static_cast<float>(x), static_cast<float>(y), 1.0f - y / 960.0f));	
		sprite->setActiveAngle(angle);
	}

	void ObstacleInstance::advance(float time)
	{
		return;
	}

	Actor* ObstacleInstance::getActor()
	{
		return actor;
	}
}